
<div style="clear: both"></div>
<table style="width:100%;text-align: center" id="table" class="layui-table">
        <thead>
        <tr >
            <th  style="text-align: center" nowrap="nowrap"><textarea class="windowName" style="display: none;">${windowName}</textarea>分类</th>
            <th style="text-align: center" nowrap="nowrap">选项</th>
        </tr>
        </thead>
        <tbody>
        <tr hidden="true">
            <td>
                <select name="demensionId">
                    <#list demensionList as list>
                        <option value="${list.demId}">${list.demName}cesTodo</option>
                    </#list>
                </select>
            </td>
        </tr>
        <tr>
            <td>类型</td>
            <td>
                <input type="radio" name="orgSource" value="0" /><span>发起人</span>
                <input type="radio" name="orgSource" value="1" /><span>上一步执行者</span>
            </td>
        </tr>
        <tr>
            <td>部门类型</td>
            <td><select name="level" style="width: 70%;">
                <#list sysOrgList as ol>
                <option value="${ol.orgId}">${ol.orgName}</option>
                </#list>
            </select></td>
        </tr>
        <tr>
            <td>查找策略</td>
            <td>
                <input type="radio" name="isUpQuery" value="0" /><span>查找指定级别，为空时继续向上查询</span>
                <br>
                <input type="radio" name="isUpQuery" value="1"/><span>只查找指定级别，为空时不继续向上查询</span>
            </td>
        </tr>
        </tbody>
    </table>
</div>
    <div>
        <!--<input type="hidden" name="userId" value="${userId }">-->
    </div>
<script>
    layui.use(['table', 'layer'], function () {
        var layer = layui.layer;
        var table = layui.table;
        var setter = layui.setter;
        var $ = layui.$;


        // 获取前弹窗文本域的值
        var jsonStr = $(".thisWindowButton").siblings(".hiddenJson").text();
        var json ;
        if(jsonStr && jsonStr.length>0)
            json=eval('('+jsonStr+')');
        //判断单选框和下拉框的默认选中值
        if(json){
            //非默认
            eidtInit(json);
        }else{
            //默认
            $('input:radio[name=orgSource][value="0"]').attr('checked','true');
            $('input:radio[name=isUpQuery][value="0"]').attr('checked','true');
        }

        function eidtInit(json){
            //隐藏值 维度ID TODO 维度实体类未创建，待测试
            $('select[name=demensionId]').children().each(function(){
                if($(this).val()==json.demId){
                    $(this).attr('selected','true');
                    return false;
                }
            });
            //类型
            $('input:radio[name=orgSource][value='+json.orgSource+']').attr('checked','true');
            //部门类型
            $('select[name=level]').children().each(function(){
                if($(this).val()==json.level){
                    $(this).attr('selected','true');
                    return false;
                }
            });
            //查找策略
            $('input:radio[name=isUpQuery][value='+json.isUpQuery+']').attr('checked','true');
        }

        //保存
        $(document).on('click', '#save', function () {
            //获取选中的按钮
            var demId = $("input[name=demensionId]:checked").val();
            var level=$(' select[name=level]').val();
            var orgSource=$('input:radio[name=orgSource]:checked').val();
            var isUpQuery = $('input:radio[name=isUpQuery]:checked').val();

            var orgSourceText = $("input:radio[name=orgSource]:checked").next('span').html();
            var levelText = $('select[name=level]').find("option:selected").text();
            var isUpQueryText = $("input:radio[name=isUpQuery]:checked").next('span').html();

            var hiddenJson ="{\"demId\":\""+demId+"\",\"orgSource\":\""+orgSource+"\",\"level\":\""+level+"\",\"isUpQuery\":"+isUpQuery+"}";
            var showTxt="类型:"+orgSourceText+";部门类型:"+levelText+";查找策略:"+isUpQueryText;
            //对前弹窗的文本域赋值
            $(".hiddenJson").html(hiddenJson);
            $(".textarea").html(showTxt);
            //关闭弹窗
            layer.close(layer.index);
            return false;
        });
        //取消
        $(document).on('click', '#close', function () {
            layer.close(layer.index);
        });
    })
</script>
